package com.hushan.elevator.service.impl;

import com.hushan.elevator.dao.DeviceFourGConfigRepository;
import com.hushan.elevator.model.DeviceFourGConfig;
import com.hushan.elevator.service.DeviceFourGConfigService;
import jakarta.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class DeviceFourGConfigServiceImpl implements DeviceFourGConfigService {

    private final DeviceFourGConfigRepository deviceFourGConfigRepository;

    @Autowired
    public DeviceFourGConfigServiceImpl(DeviceFourGConfigRepository deviceFourGConfigRepository) {
        this.deviceFourGConfigRepository = deviceFourGConfigRepository;
    }

    @Override
    public List<DeviceFourGConfig> findAllDeviceFourGConfigs() {
        return deviceFourGConfigRepository.findAll();
    }

    @Override
    public DeviceFourGConfig findDeviceFourGConfigById(Integer id) {
        return deviceFourGConfigRepository.findById(id).orElse(null);
    }

    @Override
    public List<DeviceFourGConfig> findDeviceFourGConfigsByDeviceId(Integer deviceId) {
        return deviceFourGConfigRepository.findByDeviceId(deviceId);
    }

    @Override
    public List<DeviceFourGConfig> findDeviceFourGConfigsByModuleStatus(String moduleStatus) {
        return deviceFourGConfigRepository.findByModuleStatus(moduleStatus);
    }

    @Override
    public List<DeviceFourGConfig> findDeviceFourGConfigsByCarrier(String carrier) {
        return deviceFourGConfigRepository.findByCarrier(carrier);
    }

    @Override
    public List<DeviceFourGConfig> findDeviceFourGConfigsBySimCardStatus(String simCardStatus) {
        return deviceFourGConfigRepository.findBySimCardStatus(simCardStatus);
    }

    @Override
    public List<DeviceFourGConfig> findDeviceFourGConfigsByIsDeleted(Boolean isDeleted) {
        return deviceFourGConfigRepository.findByIsDeleted(isDeleted);
    }

    @Override
    public List<DeviceFourGConfig> findDeviceFourGConfigsByCreatedTimeBetween(LocalDateTime start, LocalDateTime end) {
        return deviceFourGConfigRepository.findByCreatedTimeBetween(start, end);
    }

    @Override
    public List<DeviceFourGConfig> findDeviceFourGConfigsByUpdatedTimeBetween(LocalDateTime start, LocalDateTime end) {
        return deviceFourGConfigRepository.findByUpdatedTimeBetween(start, end);
    }

    @Override
    @Transactional
    public void saveDeviceFourGConfig(DeviceFourGConfig deviceFourGConfig) {
        deviceFourGConfigRepository.save(deviceFourGConfig);
    }

    @Override
    @Transactional
    public void deleteDeviceFourGConfig(Integer id) {
        deviceFourGConfigRepository.deleteById(id);
    }
}